/*****************************************************************
 MYD Engine v0.1

 File: myd_shape.cpp
 Created: 14/06/09
*****************************************************************/

#include "myd_shape.h"
#include "graphics/myd_renderer.h"

using namespace myd;

Shape::Shape(shapeType name, shapeColor color)
: 
Entity()
{
	//set color
	int R, G, B;
	R = G = B = 0;

	if(color == BLUE) B = 255;
	if(color == GREEN) G = 255;
	if(color == RED) R = 255;
	if(color == YELLOW){R = 255; G = 255;}
	
	// set the vertex values
	ColorVertex* pkV = &(m_akVertices[0]);
	pkV->X = -0.5f;	pkV->Y = -0.5f;	pkV->Z = 1.0f;
	pkV->Color = D3DCOLOR_XRGB(R,G,B);
	
	pkV = &(m_akVertices[1]);
	pkV->X = -0.5f;	pkV->Y = 0.5f;	pkV->Z = 1.0f;
	pkV->Color = D3DCOLOR_XRGB(R,G,B);

	pkV = &(m_akVertices[2]);
	pkV->X = 0.5f;	pkV->Y = -0.5f;	pkV->Z = 1.0f;
	pkV->Color = D3DCOLOR_XRGB(R,G,B);

	if (name == SQUARE){
		pkV = &(m_akVertices[3]);
		pkV->X = 0.5f;	pkV->Y = 0.5f;	pkV->Z = 1.0f;
		pkV->Color = D3DCOLOR_XRGB(R,G,B);
	}
}

void Shape::draw(Renderer &rkRenderer) const
{
	Entity::draw(rkRenderer);
	rkRenderer.unbindTexture();
	rkRenderer.draw(m_akVertices, Renderer::TRIANGLE_STRIP, 4);
}